/**
 * @param {number[]} nums
 * @return {string}
 * 输入：nums = [3,30,34,5,9]
输出："9534330"
 */
var largestNumber = function (nums) {
  let res = ''
  const getArrToLargestNum = (arr) => {
    let index = 0
    while (true) {
      const curnumArr = arr.map((item) => (item + '').charAt(index))
      let obj = {
        name: -1,
        length: 0,
        index: null,
        arr: []
      }
      curnumArr.forEach((item, i) => {
        let curNum = parseInt(item)
        if (isNaN(curNum)) {
          const str = arr[i] + ''
          curNum = parseInt(str.charAt(index % str.length))
        }
        if (obj.name === curNum) {
          obj.length++
        } else if (obj.name < curNum) {
          obj.name = curNum
          obj.length = 1
          obj.index = i
        }
      })
      if (obj.length === 1) {
        res += arr[obj.index]
        arr.splice(obj.index, 1)
        return
      }
      index++
    }
  }

  while (nums.length) {
    getArrToLargestNum(nums)
  }
  return res
}
console.log(largestNumber([34323, 3432]))
